package pl.planuz;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class CheckActivity extends ListActivity implements OnClickListener{   
	TextView selection;
	public int idToModify;
	boolean uruchom=false;
	database dm;
	String nwydzial;
	Helper help;
	List<String[]> list = new ArrayList<String[]>();
	List<String[]> names2 =null ;
	String[] stg1;
	
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.check);
		View button1Click = findViewById(R.id.button1);
		button1Click.setOnClickListener(this);
		if(uruchom==false){
			help=new Helper();
			uruchom=true;
			}
		dm=new database(this,null,null,null);
		baza();
	      names2=dm.selectW();
		stg1=new String[names2.size()]; 

		int x=0;
		String stg;

		for (String[] name : names2) {
			stg = name[1];
			stg1[x]=stg;
			x++;
		}


		ArrayAdapter<String> adapter = new ArrayAdapter<String>(   
				this,android.R.layout.simple_list_item_1,   
				stg1);
        this.setListAdapter(adapter);
		selection=(TextView)findViewById(R.id.selection);
		
	}      

	public void onListItemClick(ListView parent, View v, int position, long id) {
		nwydzial=stg1[position];
		dm.setwydzial(stg1[position]);
		help.setwydzial(stg1[position]);
		selection.setText(stg1[position]);
	}
	public database baza()
	{
		return dm;
	}
	public void onClick(View v) {
		switch(v.getId()){

		case R.id.button1:
			Intent i = new Intent(this, CheckActivity2.class);
			startActivity(i);
			break;
		
	}
	}
	

	

}
